package net.internet;

import java.net.InetAddress;
import java.util.List;

public class LookupThread extends Thread
{
	@SuppressWarnings("rawtypes")
	private List entries;
	PooledWebLog log;
	@SuppressWarnings("rawtypes")
	public LookupThread(List entries,PooledWebLog log)
	{
		this.entries = entries;
		this.log = log;
	}
	@SuppressWarnings("unused")
	@Override
	public void run()
	{
		String entry;
		while(true)
		{
			synchronized (entries)
			{
				while(entries.size()==0)
				{
					if(log.isFinished())
					{
						return;
					}
					try
					{
						entries.wait();
					}
					catch (Exception e)
					{
					}
				}
				entry = (String) entries.remove(entries.size()-1);
			}
			int index = entry.indexOf(' ',0);
			String remoteHost = entry.substring(0,index);
			String theRest = entry.substring(index, entry.length());
			try
			{
				remoteHost = InetAddress.getByName(remoteHost).getHostName();
			}
			catch (Exception e)
			{
			}
			try
			{
				log.log(entry);
			}
			catch (Exception e)
			{
			}
		}
	}
}
